/**
 * Copyright 2008 by Robert Konigsberg
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the same terms as Perl.
 *
 * @see http://www.perl.com/perl/misc/Artistic.html
 */
package visitor.surveyor;

public class TranslatedArray {
  private final char[][] array;
  private final int minX;
  private final int maxX;
  private final int minY;
  private final int maxY;

  public TranslatedArray(int minX, int maxX, int minY, int maxY) {
    int rows = maxY - minY + 1;
    int columns = maxX - minX + 1;
    array = new char[rows][];
    for (int i = 0; i < array.length; i++) {
      array[i] = new char[columns];
    }
    this.minX = minX;
    this.minY = minY;
    this.maxX = maxX;
    this.maxY = maxY;
  }

  public void set(int x, int y, char c) {
    array[y - minY][x - minX] = c;
  }

  public char get(int x, int y) {
    return array[y - minY][x - minX];
  }

	public int getMinX() {
		return minX;
	}

	public int getMaxX() {
		return maxX;
	}

	public int getMinY() {
		return minY;
	}

	public int getMaxY() {
		return maxY;
	}

	public char[][] getArray() {
		return array;
	}
}
